package com.example.springbooksystem.mapper;

import com.example.springbooksystem.model.BookInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description：
 *
 * @author: zxj
 * @date: 2024-01-25
 * @time: 15:33:54
 */
@Mapper
public interface BookMapper {
    @Insert("insert into book_info (book_name,author,count,price,publish,status)" +
            "values (#{bookName},#{author},#{count},#{price},#{publish},#{status})")
    public Integer insert(BookInfo bookInfo);


    @Select("select * from book_info where status != 0 order by id desc limit #{offset},#{pageSize} ")
    List<BookInfo> select(int offset, int pageSize);

    @Select("select count(1) from book_info where status != 0")
    Integer count();

    @Select("select * from book_info where status != 0 and id = #{id} ")
    BookInfo selectById(Integer id);

    Integer updateBook(BookInfo bookInfo);

    Integer batchDeleteBookByIds(List<Integer> ids);
}
